package com.last1mile.dao.ibatis.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.last1mile.dao.BaseSqlMapClientDao;
import com.last1mile.dao.interfaces.MerServeDao;
import com.last1mile.pojo.MerServeDO;

@Component("merServeDao")
public class MerServeDaoImpl extends BaseSqlMapClientDao implements MerServeDao {

    @Override
    public Integer insertServe(MerServeDO merServeDo) {
        return (Integer) getSqlMapClientTemplate().insert("merServe.insertMerServe", merServeDo);
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<MerServeDO> queryServeByMerId(Integer merId) {
        List<MerServeDO> records = (List<MerServeDO>) getSqlMapClientTemplate().queryForList("merServe.selectByMerId",
                                                                                             merId);
        return records;
    }

    @SuppressWarnings("unchecked")
    @Override
    public List<MerServeDO> queryServeByAddrExceptUser(MerServeDO merServeDo) {
        MerServeDO key = new MerServeDO();
        key.setAddrCountry(merServeDo.getAddrCountry());
        key.setAddrState(merServeDo.getAddrState());
        key.setAddrCity(merServeDo.getAddrCity());
        key.setAddrDistrict(merServeDo.getAddrDistrict());
        key.setMerId(merServeDo.getMerId());
        List<MerServeDO> records = (List<MerServeDO>) getSqlMapClientTemplate().queryForList(
                                                                                             "merServe.selectByAddrExceptUser",
                                                                                             key);
        return records;
    }

    @Override
    public MerServeDO queryServeById(Integer id) {
        MerServeDO record = (MerServeDO) getSqlMapClientTemplate().queryForObject("merServe.selectById", id);
        return record;
    }
    
    @SuppressWarnings("unchecked")
	public List<MerServeDO> queryServesByIdList(List<Integer> ids){
    	List<MerServeDO> records = (List<MerServeDO>) getSqlMapClientTemplate().queryForList("merServe.selectByIds", ids);
    	return records;
    }
}
